package com.yili.oa.service.impl;

import com.yili.oa.dao.AdminMapper;
import com.yili.oa.dao.extend.AdminExtendMapper;
import com.yili.oa.models.Admin;
import com.yili.oa.utils.annotate.DataBase;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@DataBase
@Transactional
public class TestService {

    @Resource
    private AdminMapper mapper;

    @Resource
    private AdminExtendMapper adminExtendMapper;


 /*   public void update(Long id) throws Exception{
        Admin admin = adminExtendMapper.selectByUserName(id+"");
        String availableCommission = admin.getAvailableCommission();
        List<LowerData> list = JSONObject.parseArray(availableCommission, LowerData.class);
        list.forEach(lowerData->{
            BigDecimal bigDecimal = BigDecimal.ZERO;
            lowerData.setAvailableCommission(bigDecimal);
        });
        System.err.println("开始");
        Thread.sleep(10000);
        Object o = JSONObject.toJSON(list);
        admin.setAvailableCommission(o.toString());
        mapper.updateByPrimaryKeySelective(admin);
        System.err.println("结束");
    }*/

    public void test1() throws Exception{
        adminExtendMapper.selectByUserName("16");
        System.err.println("test1");
        Thread.sleep(10000);
        Admin admin = new Admin();
        admin.setPassword("1");
        admin.setUsername("16");
        admin.setIsAdmin(0);
        admin.setCreateTime(14654L);
        mapper.insert(admin);
        System.err.println("test1------");

    }

    public void test2() throws Exception{
        adminExtendMapper.selectByUserName("17");
        System.err.println("test2");
        Thread.sleep(10000);
        Admin admin = new Admin();
        admin.setPassword("1");
        admin.setUsername("17");
        admin.setIsAdmin(0);
        admin.setCreateTime(14654L);
        mapper.insert(admin);
        System.err.println("test2------");
    }



}
